package TeamSoccer;

public class Team implements Comparable<Team>{
	private String nama;
	private int win;
	private int draw;
	private int lose;
	private int goal;
	private int con;
	private int point;
	private boolean lastPlay;
	
	public boolean isLastPlay() {
		return lastPlay;
	}

	public void setLastPlay(boolean lastPlay) {
		this.lastPlay = lastPlay;
	}

	public Team(String nama){
		this.nama=nama;
	}
	
	public String getNama() {
		return nama;
	}

	public void setNama(String nama) {
		this.nama = nama;
	}

	public int getWin() {
		return win;
	}

	public void setWin(int win) {
		this.win = win;
	}

	public int getDraw() {
		return draw;
	}

	public void setDraw(int draw) {
		this.draw = draw;
	}

	public int getLose() {
		return lose;
	}

	public void setLose(int lose) {
		this.lose = lose;
	}

	public int getPoint() {
		return point;
	}

	public void countPoint(){
		point = (win*3)+(draw*1);
	}
	
	public void setGoal(int goal) {
		this.goal = goal;
	}

	public void setCon(int con) {
		this.con = con;
	}
	
	public int getGoal() {
		return goal;
	}

	public int getCon() {
		return con;
	}

	public int getDifGoalCon(){
		return goal-con;
	}

	public String GoalCon(){
		return goal+"-"+con;
	}
	
	public String printSpace(int length,int word){
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<(length-word);i++){
			sb.append(" ");
		}
		return sb.toString();
	}
	
	
	@Override
	public String toString(){
		String mark="";
		if(this.isLastPlay()) mark="*";
		return nama+printSpace(16,nama.length())+(win+draw+lose)+printSpace(6,Integer.toString((win+draw+lose)).length())+
		 win+printSpace(6,Integer.toString(win).length())+draw+printSpace(6,Integer.toString(draw).length())+
		 lose+printSpace(6,Integer.toString(lose).length())+goal+"-"+con+printSpace(7,Integer.toString(con).length())+
		 point+" "+mark;
	}
	
	@Override
	public boolean equals(Object o){
		Team p = (Team) o;
		if((o instanceof Team) && (p.getNama().equals(this.getNama())))
			return true;
		else
			return false;
	}
	
	@Override
	public int hashCode(){
		return getNama().length();
	}

	@Override
	public int compareTo(Team team) {
		return this.getNama().compareTo(team.getNama());
	}
	
}
